package	com.sdry.web.controller.tdd.receiveTips;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sdry.model.tdd.receiveTips.ReceiveTips;
import com.sdry.model.tdd.receiveTips.ReceiveTipsDetails;
import com.sdry.service.tdd.receiveTips.ReceiveTipsDetailsService;
import com.sdry.service.tdd.receiveTips.ReceiveTipsService;
import com.sdry.utils.ResponseUtil;
import com.sdry.web.controller.tdd.emailRecord.EmailRecordController;
/**
 *
 *@ClassName: ReceiveTipsController
 *@Description: 收货一定时间未上架
 *@Author tdd
 *@Date 2019-09-12 14:19:05
 *@version 1.0
*/
@Controller
@RequestMapping("/receiveTips")
public class ReceiveTipsController{
	@Resource ReceiveTipsService receiveTipsService;
	@Resource ReceiveTipsDetailsService receiveTipsDetailsService;
	//声明一个Logger
	private final static Logger logger = LoggerFactory.getLogger(EmailRecordController.class);
	/** 
	 * 进入页面
	 * @param model
	 * @return 页面路径
	*/
	@RequestMapping("/page")
	public String pageReceiveTips (Model model) {
		return "/td/receiveTips";
	}
	
	/** 
	 * 条件分页查询
	 * @param param 实体条件
	 * @param response
	 * @throws Exception
	*/
	@RequestMapping("/list")
	public void list(ReceiveTips param,HttpServletResponse response){
		logger.info("receiveTips/list.do收货一定时间未上架条件分页查询接收数据：ReceiveTips = "+JSONArray.fromObject(param));
		/*
		 * 条件分页查询内容
		 */
		List<ReceiveTips> list = receiveTipsService.findPageByMution(param);
		/*
		 * 条件查询总条数
		 */
		Integer total = receiveTipsService.selectCountByMution(param);
		/*
		 * 转为json数据传至页面
		 */
		//创建result
		JSONObject jsonObject = new JSONObject();
		//添加入jsonObject
		jsonObject.put("code", 0);
		jsonObject.put("rows", list);
		jsonObject.put("total", total);
		logger.info("收货一定时间未上架条件分页查询传送数据:rows:List<ReceiveTips>="+JSONArray.fromObject(list)+";total="+total);
		try {
			ResponseUtil.write(response, jsonObject);
		} catch (Exception e) {
			logger.info("收货一定时间未上架条件分页查询传送数据失败");
			e.printStackTrace();
		}
	}
	/**
	 * 根据入库未上架分页查询条件查询入库未上架及其详情
	 * @param param
	 * @param response
	 */
	@RequestMapping("/selectAllByReceiveTips")
	@ResponseBody
	public List<ReceiveTipsDetails> selectAllByReceiveTips(ReceiveTips param){
		logger.info("根据入库未上架分页查询条件查询入库未上架及其详情接收数据：ReceiveTips = "+JSONArray.fromObject(param));
		//根据入库未上架分页查询条件查询入库未上架及其详情
		List<ReceiveTipsDetails> list = receiveTipsDetailsService.selectAllByReceiveTips(param);
		logger.info("根据入库未上架分页查询条件查询入库未上架及其详情传送数据：List<EmailRecord> = "+JSONArray.fromObject(list));
		return list;
	}
}
